package com.mxpio.erp.common.sales.entity;

import java.math.BigDecimal;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.mxpio.erp.common.jpa.model.BizOrder;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.User;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_SALES_SO")
@Schema(description="销售订单")
public class SalesOrder extends BizOrder {

	private static final long serialVersionUID = 1L;

	@Column(name = "ORDER_TYPE_")
	@Schema(description = "单据类型")
	@Dict(dicCode="ERP_SALES_ORDER_TYPE")
	private String orderType;

	@Column(name = "BIZ_TYPE_")
	@Schema(description = "业务类型")
	@Dict(dicCode = "ERP_SALES_BIZ_TYPE")
	private String bizType;

	@Column(name = "CONTRACT_YEAR_")
	@Schema(description = "合同年份")
	private Integer contractYear;

	@Column(name = "CONTRACT_REVIEW_")
	@Schema(description = "合同评审")
	private String contractReview;

	@Column(name = "CONTRACT_NO_")
	@Schema(description = "合同编号")
	private String contractNo;

	@Column(name = "IN_CONTRACT_NO_")
	@Schema(description = "厂内合同编号")
	private String inContractNo;

	@Column(name = "BIZ_MAN_")
	@Schema(description = "业务员")
	@Dict(dicCode = "username",dicEntity = User.class,dicText = "nickname")
	private String bizMan ;

	@Column(name = "PN_CODE_")
	@Schema(description = "客户编号")
	private String pnCode;

	@Column(name = "PN_NAME_")
	@Schema(description = "客户名称")
	private String pnName;

	@Column(name = "PN_ABBR_")
	@Schema(description = "公司简称")
	private String pnAbbr;

	@Column(name = "PN_CONTACTS_")
	@Schema(description = "客户联系人")
	private String pnContacts;

	@Column(name = "PN_ADDRESS_")
	@Schema(description = "客户地址")
	private String pnAddress;

	@Column(name = "PN_PHONE_")
	@Schema(description = "手机")
	private String pnPhone;

	@Column(name = "PN_TEL_")
	@Schema(description = "电话")
	private String pnTel;

	@Column(name = "PN_FAX_")
	@Schema(description = "传真")
	private String pnFax;

	@Column(name = "INVOICE_TYPE_")
	@Schema(description = "发票类型")
	@Dict(dicCode = "ERP_SALES_INVOICE_TYPE")
	private String invoiceType;

	@Column(name = "TAX_RATE_")
	@Schema(description = "税率")
	private BigDecimal taxRate;

	@Column(name = "EXCHANGE_RATE_")
	@Schema(description = "汇率")
	private BigDecimal exchangeRate;

	@Column(name = "CURRENCY_")
	@Schema(description = "币种")
	@Dict(dicCode = "ERP_COMMON_CURRENCY")
	private String currency;

	@Column(name = "RECEIVING_COMPANY_")
	@Schema(description = "收货单位")
	private String receivingCompany;

	@Column(name = "ADDRESS_")
	@Schema(description = "收货地址")
	private String address;

	@Column(name = "CONSIGNEE_")
	@Schema(description = "收货人")
	private String consignee;

	@Column(name = "ADDR_TEL_")
	@Schema(description = "联系电话")
	private String addrTel;

	@Column(name = "MEMO_")
	@Schema(description = "备注")
	private String memo;

	@Column(name = "PROCESS_INSTANCE_ID_")
	@Schema(description = "流程实例ID")
	private String processInstanceId;

	@Transient
	private List<SalesOrderLine> salesOrderLines;


	@Override
	public String initTypeCode() {
		return "SO1";
	}
}
